<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>16_判断数据类型</title>
</head>

<body>


  <!-- group -->
  <script>
    // // typeof  只能准确的检测基本数据类型
    // console.group('group1-typeof基本数据类型')
    // console.log(typeof (123))//number
    // console.log(typeof ('abc'))//string
    // console.log(typeof (true))//boolean
    // console.log(typeof (undefined))//undefined
    // console.log(typeof (null))//object
    // console.groupEnd()

    // console.group('typeof+引用数据类型')
    // console.log(typeof ([1, 2]))//object
    // console.log(typeof ({ name: 'Jack' }))//object
    // console.log(typeof (function () { }))//function
    // console.log(typeof (new Date()))//object
    // console.groupEnd()


    /* 使用Object自带的toString实例方法打印变量类型 */
    // console.group('typeof+引用数据类型')
    // console.log( Object.prototype.toString.call(null) )//[object Null]
    // console.log( Object.prototype.toString.call([]) )//[object Array]
    // console.log( Object.prototype.toString.call({}) )//[object Object]
    // console.log( Object.prototype.toString.call(function () {}) )//[object Function]
    // console.log( Object.prototype.toString.call(new Date()) )//[object Date]
    // console.groupEnd()

    /* 以下这段代码为选学 */
    const d = new Date()
    console.log(Object.prototype.toString.call(d));
    const fn = Object.prototype.toString
    d.pt = fn
    console.log(
      d.pt()//已d为主语（this）调用pt方法=fn方法=Object.prototype.toString
    );
   

  </script>
</body>

</html>